<!DOCTYPE html>
<html>

<head>
    <title>游记列表</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/plugins/jquery/jquery.min.js"></script>
    <script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/travel.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>

    <script>
        $(function () {
            $(".search").click(function () {
                var value = $('.searchBtn').val();
                if(value){
                    sessionStorage.setItem("keyword",JSON.stringify(value))
                    sessionStorage.setItem("delete",JSON.stringify("3"))
                    window.location.href="/checkMessage.html";
                }
            })


            //首先我们需要获取当前页的标签
            var currentInput = $('#currentPage');
            //因为我们手机滚动之前的数据就没有了,只有当前查出来的不合理
            var arr=[];
            var pages=1;
            function query() {
                //获取当前页
                var currentPage = currentInput.val();
                $.get("/travels",{currentPage:currentPage},function (data) {
                    pages=data.pages;
                    //把两个数组的数据合并在一起,就可以滚动了
                    $.merge(arr,data.list);
                    var json={
                        list:arr
                    }
                    $('#allTravels').renderValues(json,{
                        getHref:function (item,value) {
                            var href = $(item).data("href");
                            $(item).attr("href",href+value);
                        }
                    });
                });

                currentInput.val(parseInt(currentPage)+1);
            }
            query();
            $(window).scroll(function () {
                if($(document).scrollTop()+$(window).height()>=$(document).height()){
                    var val = currentInput.val();
                    if(val<=pages){
                        query();
                    }else{
                        $(document).dialog({
                            type : 'notice',
                            infoText: '已经加载到底了!!!',
                            autoClose: 1000
                        });
                    }
                }
            });

            $.get("/travels/commends",{type:2,pageSize:3},function (data) {
                $('.carousel-inner').renderValues(data,{
                    getHref:function (item,value) {
                        var href = $(item).data("href");
                        $(item).attr("href", href + value);
                    }
                });
                $('.carousel-item:first').addClass("active");
            })

        });
    </script>
</head>

<body>


<div class="search-head">
    <div class="row nav-search">
        <div class="col-2">
            <a href="index.html">
                <span><i class="fa fa-chevron-left fa-2x"></i></span>
            </a>
        </div>
        <div class="col-10">
            <div class="input-group-sm search">
                <input class="form-control searchBtn" placeholder="搜游记">
            </div>
        </div>
    </div>
</div>


<div class="container">

    <h6>每月冠军游记</h6>
    <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
        <div id="travelsCommends" class="carousel-inner" render-loop="list">
            <div ><div class="carousel-item ">
                <div class="border commend">
                    <a data-href="travelContent.html?id=" render-key="list.travel_id" render-fun="getHref">
                        <img render-src="list.coverUrl" width="100%" height="200px">
                        <h1 render-html="list.title"> </h1>
                        <small  render-html="list.subTitle"></small>
                    </a>
                </div>
            </div></div>
        </div>

        <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
            <span class="sr-only"></span>
        </a>
        <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="sr-only"></span>
        </a>
    </div>
</div>
<input type="hidden" name="currentPage" id="currentPage" value="1"/>
<div class="container">
    <h6>全部游记</h6>
    <div id="allTravels">
     <div render-loop="list">

        <div class="row detail">
            <div class="col">
                <a data-href="travelContent.html?id="  render-key="list.id" render-fun="getHref">
                    <h4 render-html="list.title"></h4>
                </a>
                <p>
                    <a data-href="userProfiles.html?authorId="  render-key="list.author.id" render-fun="getHref">
                        <img class="rounded-circle head-img" render-src="list.author.headImgUrl">
                        <span render-html="list.author.nickName"></span> </a> 在
                    <span class="addr" render-html="list.place.name"></span>

                </p>
                <p>
                    <i class="fa fa-eye fa-fw"></i>
                    <span>0</span>
                    <i class="fa fa-commenting fa-fw"></i>
                    <span>0</span>
                </p>
            </div>
            <div class="col bigimg">
                <a data-href="travelContent.html?id="  render-key="list.id" render-fun="getHref" >
                    <img render-src="list.coverUrl">
                </a>
            </div>
        </div>
     </div>
    </div>
</div>



</body>

</html>